perm filename LOOK.FAI[HAK,HPM]5 blob sn#322298 filedate 1977-12-06 generic text, type C, neo UTF8
COMMENT āŠ—   VALID 00002 PAGES
C REC  PAGE   DESCRIPTION
C00001 00001
C00002 00002		title	look
C00006 ENDMK
CāŠ—;
	title	look
start:	OUTSTR	[ASCIZ \LINE #:\]
	MOVEI	10,0
NUMC:	INCHWL	2
	CAIE	2,40
	CAIN	2,11
	JRST	NUMC
	SUBI	2,60
	CAIL	2,=0
	CAILE	2,=7
	JRST	TOFC
	IMULI	10,10
	ADD	10,2
	JRST	NUMC
TOFC:   MOVE	1,10
	JUMPG	1,FIZ
	MOVE	2,[XWD	-1,[XWD 1700,1]]
	TTYSET	2,
	movni	1,1		;getlin wants neg arg
	getlin	1		;get the line number
	tlnn	1,20000		;is it a dd?
	jrst	[outstr	[asciz	/ Not a data disk, can't map
/]
		exit]
FIZ:	subi	1,20		;make it a physical line number
	hrrm	1,line		;deposit line number
	move	1,[400012,,map]	;setup word for spacewar process
	spcwgo	1,
	setom	allook#		;default to looking at all channels

loop:	skipe	allook
	jrst	all
	move	1,[-40,,0]
	setzm	dduse#
	movsi	3,400000
gdd:	movei	2,200(1)
	ddchan	2,
	tlnn	2,200		;only look at channels which are not system
	tlnn	2,377		;and are in use by somebody
	skipa
	iorm	3,dduse
	lsh	3,-1
	aobjn	1,gdd
	skipa
all:	setom	dduse
	inchrw	1
	cain	1,"+"
	jrst	forwrd
	cain	1,"-"
	jrst	backwd
	cain	1,15		;carriage return to exit
	exit
	caie	1,"n"
	cain	1,"N"
	jrst	normal
	caie	1,"r"
	cain	1,"R"
	jrst	rinuse
	movei	2,0
	caig	1,"9"
	caige	1,"1"
	jrst	stop		;set direction to 0 to stop movement
	subi	1,"0"
	hrrm	1,intrvl	;set number of 1/6-sec intervals per map
	jrst	loop
forwrd:	movei	2,1		;set direction forward
	skipa
backwd:	movei	2,-1		;set direction backward
stop:	movem	2,direct
	jrst	loop
normal:	setom	allook		;set looking at all channels
	jrst	loop
rinuse:	setzm	allook		;set looking at in use only channels
	jrst	loop

map:	sosle	timec		;n'th tic?
	dismis			;no
intrvl:	movei	10,6		;default n = 6 for 1 map per second
	movem	10,timec
map1:	skipe	dduse		;get out if not looking at any channels
	skipn	direct		;aren't moving
	dismis
	move	10,direct
	addb	10,chanel	;current dd channel being looked at
	andi	10,37		;mask out all but bottom 5 bits
	movn	10,10		;prepare for shift right
	hrlzi	11,400000
	lsh	11,(10)
	and	11,dduse
	jumpe	11,map1		;try again if we're not looking at this one
line:	cono	340,21		;default line is mine
	datao	340,11
byebye:	dismis

timec:	0			;start with 1 map per second
chanel:	0			;initial chanel is 0
direct:	1			;initial direction is forward

	end	start